'''
Created on 2011-2-6
Implement:
    getLocations(self, workspaces, src_dir = 'src')
@author: wilbur.ma
'''

import os

from pwilib.util.plugin.schema.Crawler import LocationCrawler

class EclipseSrcCrawler(LocationCrawler):
    ignoreDirs = ('.metadata',
                  )
    
    def getLocations(self, workspaces, src_dir = 'src'):
        tmp_src = workspaces.split(os.pathsep)
        src = {s:os.listdir(s) for s in tmp_src}
        
        for s in src.keys():  # key: eclipse workspace
            for d in src[s]:  # value: list of workspace projects
                if d not in EclipseSrcCrawler.ignoreDirs:
                    self.locations.append(os.path.join(s, d, src_dir))
                    
        return self.locations
                    
    
def main():
    c = EclipseSrcCrawler()
    print(c.getLocations('F:\p\workspace;F:\p\python'))
    
if __name__ == '__main__':
    main()